package com.sdgc.mapper;

import com.sdgc.pojo.Emp;
import com.sdgc.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

//员工基本信息mapper
@Mapper
public interface EmpMapper {
//-----------------------------------原始分页查询方法实现-----------------------------------------
//    查询总记录数
//    @Select("select count(*) from emp e left join dept d on e.dept_id = d.id")
//    public Long count();

    //分页查询
    //                                                                      order by e.update_time desc
//    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id limit #{start},#{pageSize}")
//    public List<Emp> list(Integer start, Integer pageSize);

//    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id")
    public List<Emp> list(EmpQueryParam empQueryParam);
//    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id")
//    List<Emp> listAll();

    //    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id")
//    public List<Emp> list(Integer start, Integer pageSize);



    //新增员工基本信息
    @Options(useGeneratedKeys = true,keyProperty = "id")//主键返回
    @Insert("insert into emp(username,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time)"+
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);


    void deleteByIds(List<Integer> ids);


    Emp getById(Integer id);


    //根据id更新员工基本信息
    void updateById(Emp emp);
}
